/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	         </p>
 * <p>创建者   :	lei 
 * 
 * <p>描   述  :   TecEvalutionController.java for com.pengtu.gsj.controller.yh    </p>
 * 
 * <p>最后修改 : $: 2017年6月5日-下午3:48:13 v 1.0.0	 lei   $ </p>
 * 
*/

package com.pengtu.gsj.controller.yh;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.yh.TecEvalution;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.yh.TecevalutionService;
import com.pengtu.gsj.utils.web.SpringMvcUtils;

/**
 * 
 * TecEvalutionController
 * 
 * 2017年6月5日 下午3:48:13
 * @author lei
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("tecEvalut")
public class TecEvalutionController extends DefaultBaseController{
	
	@Autowired
	private TecevalutionService tecevalutionService;

	@ModelAttribute
	public TecEvalution loadEntity(String id) {
		TecEvalution tecEvalution = null;
		if (StringUtils.isNotEmpty(id)) {
			tecEvalution = tecevalutionService.getTecevalution(id);
		} else {
			tecEvalution = new TecEvalution();
		}
		return tecEvalution;
	}
	
	@Token(save = true)
	@RequestMapping("listInfo")
	public String showLisfInfo() {
		return "yh/tecEvalut_list";
	}
	
	@ResponseBody
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	public Page<TecEvalution> getTecEvalutionList(Page<TecEvalution> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("tecYear");
			page.setOrder(Page.ASC);
		}
		page = tecevalutionService.findTecevalutions(page, queryFilter);
		return page;
	}
	
	@ResponseBody
	@Token(remove = true)
	@RequestMapping(value = "save", method=RequestMethod.POST)
	public boolean saveTecEvalution(@ModelAttribute TecEvalution tecEvalution) {
		tecevalutionService.saveTecevalution(tecEvalution);
		return true;
	}
	
	@ResponseBody 
	@RequestMapping(value="show")
	public TecEvalution showTecEvalution (@ModelAttribute TecEvalution tecEvalution){
		return tecEvalution;
	}
	
	@ResponseBody
	@RequestMapping(value="delete")
	public boolean deleteTecEvalution(@ModelAttribute TecEvalution tecEvalution){
		tecevalutionService.deleteTecevalution(tecEvalution);
		return true;
	}
	
	@ResponseBody
	@RequestMapping("checkTecYear")
	public boolean checkTecYear(){
		String tecYear = SpringMvcUtils.getParameter("tecYear");
		String id = SpringMvcUtils.getParameter("id");
		return tecevalutionService.checkTecYear(tecYear, id);
	}
}
